647. 回文子串
class Solution {
    public int countSubstrings(String s) {
        char[] str = s.toCharArray();
        int len = str.length;
        int[][] dp = new int[len][len];
        int count = 0;
        for (int i = 0; i  len; i++) {
            for (int j = i; j = 0; j--) {
                if (i == j) {
                    count++;
                    dp[i][j] = 1;
                } else if (str[i] == str[j] && j+1 == i) {
                    count++;
                    dp[i][j] = 1;
                } else if (str[i] == str[j]) {
                    dp[i][j] = dp[i-1][j+1] == 1  1  0;
                    if (dp[i][j] == 1) {
                        count++;
                    }
                }
            }
        }
        return count;
    }
}